<template>
	<Layout class="p-5 bg-white">
		<Form :label-width="100">
			<FormItem class="w-50" label="会员券名称">
				<label>{{voucherRecord.name}}</label>
			</FormItem>
			<FormItem class="w-50" label="卡号">
				<label>{{voucherRecord.uuId}}</label>
			</FormItem>
			<FormItem class="w-50" label="密码">
				<label>{{voucherRecord.password}}</label>
			</FormItem>
			<!-- <FormItem class="w-100" label="有效时长/天">
				<label>{{voucherRecord.timeLongs/60/24}}</label>
			</FormItem> -->
			<FormItem class="w-50" label="创建时间">
				<label>{{voucherRecord.ct}}</label>
			</FormItem>
			<FormItem class="w-50" label="激活时间">
				<label>{{voucherRecord.st}}</label>
			</FormItem>
			<FormItem class="w-50" label="结束时间">
				<label>{{voucherRecord.et}}</label>
			</FormItem>
			<FormItem class="w-50" label="会员券状态">
				
				<Select :class="'w-25 m-2'" v-model="voucherRecord.statu" placeholder="请选择会员券状态">
					<Option v-for="item in voucherStatu" :value="item.value" :key="item.value">{{ item.label }}</Option>
				</Select>
			</FormItem>
			
			<FormItem class="text-right">
				<Button @click="submit" type="primary">提交</Button>
				<Button @click="cancel" class="ml-2">取消</Button>
			</FormItem>
		</Form>
	</Layout>
</template>

<script>
	export default {
		data() {
			return {
				voucherRecord: {
					recordId:"",
					voucherTypeName: "",
					uuId: "",
					password: "",
					timeLongs: "",
					ct: "",
					st: "",
					et: "",
				    statu: 0,
				},
				voucherStatu:[
					{
						value:  1,
						label: '可用'
					},
					{
						value:  0,
						label: '禁用'
					},
				]
				
			}
		},
		methods: {
			
			submit: function() {
				this.http.put({
					url: "/client/voucher-record/info",
					param:{
						voucherRecord:this.$data.voucherRecord
					}
				}).then(data => {
					this.message.info("修改成功");
					this.$tabs.close();
					this.$tabs.open("/voucher")
				});
		
			},
			cancel: function() {
				// this.$router.go(-1);
				this.$tabs.close();
			},
			init: function() {
				this.search();
			},
			search: function() {
				this.http.get({
					url: "/client/voucher-record/info",
					param: {
						voucherId: this.$data.voucherRecord.recordId
					}
				}).then(data => {
					if(null != data.ct){
						data.ct = data.ct.replace('T',' ')
					}
					if(null != data.st){
						data.st = data.st.replace('T',' ')
					}
					if(null != data.et){
						data.et = data.et.replace('T',' ')
					}
					this.$data.voucherRecord = data;
					
					if(this.$data.voucherRecord.statu){
						this.$data.voucherRecord.statu =1;
					}else{
						//alert('0')
						this.$data.voucherRecord.statu =0;
					}
					
				});
			},
		},
		created: function() {
			this.$data.voucherRecord.recordId = this.$route.params.recordId;
			
			this.init();
		}
		
	}
</script>
